package com.sinosoft.front;

import java.rmi.RemoteException;

import org.apache.log4j.Logger;

import com.sinosoft.front.dto.common.xsd.IinsuranceExtensionEhm;
import com.sinosoft.front.dto.common.xsd.TxInsuranceRequestEhm;
import com.sinosoft.front.dto.common.xsd.TxInsuranceRequestExtensionEhm;
import com.sinosoft.front.dto.xsd.CarActualPriceQueryRequest;
import com.sinosoft.front.dto.xsd.CarActualPriceQueryResponse;
import com.sinosoft.front.service.CarActualPriceQueryServicePortType;
import com.sinosoft.front.service.CarActualPriceQueryServicePortTypeProxy;

public class Test {

	static Logger logger = Logger.getLogger(Test.class);
	public static void main(String[] args) throws RemoteException {
		
		//调用服务器端方法
		        CarActualPriceQueryServicePortTypeProxy proxy = new CarActualPriceQueryServicePortTypeProxy();
				proxy.setEndpoint("http://proxy.tuxing51.com/frontServiceCenter/services/CarActualPriceQueryService?wsdl");
				CarActualPriceQueryServicePortType carActualPriceQueryServicePortType = proxy.getCarActualPriceQueryServicePortType();
				logger.info("======车辆实际价值计算服务======");
				//请求头信息
				CarActualPriceQueryRequest request = new CarActualPriceQueryRequest();
				TxInsuranceRequestEhm requestEhm = new TxInsuranceRequestEhm();
				requestEhm.setTransExeDate("2017-3-17");
				requestEhm.setTransExeTime("12:24:34");
				request.setTxInsuranceRequestEhm(requestEhm);
				
				requestEhm.setIinsuranceExtensionEhm(new IinsuranceExtensionEhm());
			
				//请求头数据
				TxInsuranceRequestExtensionEhm extensionEhm = new TxInsuranceRequestExtensionEhm();
				extensionEhm.setOperator("HN1_Test");
				extensionEhm.setOperatorKey("123456");
				request.setTxInsuranceRequestExtensionEhm(extensionEhm );
				
				request.setPolicySort("HN1");//系统来源
				request.setPurchasePrice(177800.0);//新车购置价
				request.setEnrollDate("2016-06-15");//初次登记日期
				request.setStartDate("2017-04-30");//商业险起保日期
				request.setUseNatureCode("8A");//使用性质
				request.setCarKindCode("A0");//车辆种类
				request.setCityAreaCode("410500");
				logger.info("传入参数：");
				logger.info("系统来源："+request.getPolicySort()+"，新车购置价："+request.getPurchasePrice()+
						"，初次登记日期："+request.getEnrollDate()+"，商业险起保日期，"+request.getStartDate()+"，使用性质："+
						request.getUseNatureCode()+",车辆种类:"+request.getCarKindCode()+",城市代码："+request.getCityAreaCode());
				CarActualPriceQueryResponse response = carActualPriceQueryServicePortType.queryActualPrice(request);
				logger.info("返回内容：");
				System.out.println(response.getTxInsuranceResponseEhm().getTransResultEhm().getResultCode());
				System.out.println(response.getTxInsuranceResponseEhm().getTransResultEhm().getResultInfoDesc());
				System.out.println(response.getTxInsuranceResponseEhm().getTransResultEhm().getErrorNo());
				logger.info("返回码："+response.getTxInsuranceResponseEhm().getTransResultEhm().getResultCode());
				logger.info("返回内容："+response.getTxInsuranceResponseEhm().getTransResultEhm().getResultInfoDesc());
				logger.info("返回错误代码："+response.getTxInsuranceResponseEhm().getTransResultEhm().getErrorNo());
				
				logger.info("系统来源："+response.getPolicySort());
				logger.info("折旧率："+response.getSumDepreciationRate());
				logger.info("车辆实际价值:"+response.getActualPrice());
				logger.info("-------------------------------------------");
				System.out.println("折旧率："+response.getSumDepreciationRate());
				System.out.println("车辆实际价值:"+response.getActualPrice());
	}
}
